package model

import (
	"gorm.io/gorm"
	"week1zk-project/user-rpc/global"
)

//用户表

type User struct {
	gorm.Model
	Username   string `gorm:"type:varchar(30);not null;"`
	Password   string `gorm:"type:char(32);not null;"`
	ConfirmPwd string `gorm:"type:char(32);not null;comment:再次确认密码"`
	Email      string `gorm:"type:varchar(255);"`
	Mobile     string `gorm:"type:char(11);not null;"`
}

//用户注册

func (u *User) Register() error {
	return global.DB.Create(&u).Error
}

func (u *User) Login(username, password string) error {
	return global.DB.Where("username = ? and password =?", username, password).Error

}
